.NET Framework Class Library |
BlockingCollection<(Of <(T>)>)..::.Take Method (CancellationToken) |
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback |
Takes an item from the BlockingCollection<(Of <(T>)>).
Namespace:
System.Collections.Concurrent
Assembly:
System.Threading (in System.Threading.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Function Take ( _ cancellationToken As CancellationToken _ ) As T |
C# |
---|
public T Take( CancellationToken cancellationToken ) |
Parameters
- cancellationToken
- Type: System.Threading..::.CancellationToken
Return Value
The item removed from the collection.Remarks
A call to Take(CancellationToken) may block until an item is available to be removed.
Exceptions
Exception | Condition |
---|---|
System..::.OperationCanceledException | If the CancellationToken is canceled or the BlockingCollection<(Of <(T>)>) is empty and has been marked as complete with regards to additions. |
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed. |
System..::.InvalidOperationException | The underlying collection was modified outside of this BlockingCollection<(Of <(T>)>) instance. |